import java.util.Arrays;

public class Quick {
    public static void main(String[] args) {
        int[] arr = {10, 44, 23, 242, 111, 2, 0};
        new Quick().quickSort(arr, 0, arr.length-1);
        System.out.println(Arrays.toString(arr));
    }
    public void quickSort(int [] a,int start,int end){
        if(start<end){
            int index = getIndex(a, start, end);
            quickSort(a, start, index-1);
            quickSort(a, index+1, end);
        }
    }
    public int getIndex(int [] a,int start,int end){
        int i = start;
        int j = end;
        int x = a[i];
        while(i<j){
            while (i<j&&a[j]>=x){
                j--;
            }if(i<j){
                a[i]=a[j];
                i++;
            }
            while (i<j&&a[i]<=x){
                i++;
            }if(i<j){
                a[j]=a[i];
                j--;
            }
        }
        a[i]=x;
        return i;
    }
}
